import { ApiDoctorComment  } from "../../../api/index"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    loading: false,
    finish: false,
    parmas: {
      page: 1,
      size: 15,
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.data.id = options.id
    this.getComment()
  },
  getComment() {
    this.setData({
      loading: true
    })
    ApiDoctorComment(this.data.parmas,this.data.id).then(res => {
      const list = this.data.parmas.page === 1 ? res.data : this.data.list.concat(res.data)
      const finish = list.length >= res.page.total
      this.setData({
        list,
        finish
      })
    }).finally(_=>{
      this.setData({
        loading: false
      })
    })
  },
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if(this.data.loading || this.data.finish) return
    this.data.parmas.page += 1
    this.getComment()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})